package Project;

import java.awt.event.KeyEvent;
import java.util.ArrayList;


/** 
 * This singleton class contains constants that are to be used for the system. 
 * Includes custom user controls.
 * 
 * @author	Brian Wetherbee
 * 			Ryan McNamara
 * 			Zeng Yang
 *
 */
public class Constants {
	//ensures that this is a singleton
	private Constants(){}
	
	
	
	/*@ requires Constants.CONSTANTS_SET_UP == false;
	  @ ensures Constants.CONSTANTS_SET_UP == true;
	 @*/
	public static void setUpConstants(){

    	int i = 0;
        Constants.TitleScreenNum = i;
        i++;
        Constants.StoryNum = i;
        i++;
        Constants.GalaxyMapNum = i;
        i++;
        Constants.TitleScreenLoadGame = i;
        i++;
        
		//set up max upgrade status
        Constants.MAX_UPGRADE_STATUS = new ArrayList<ArrayList<Integer>>();
		Constants.UPGRADE_COSTS = new ArrayList<ArrayList<ArrayList<Integer>>>();
		setupWeaponAttributes();
		
		
		
		
		
		int numOptions = 0;
		for(ArrayList<Integer> a : Constants.MAX_UPGRADE_STATUS) {
			numOptions += a.size();
		}
		// Constants.NUM_WEAPON_ATTRIBUTES = numOptions;
		Constants.NUM_WEAPON_ATTRIBUTES = 3;
		
		setDefaultConstrols();
		
	}
	
	/*@requires true
	  @ensures true
	 */
	public static void setDefaultConstrols(){
		controlUp = java.awt.event.KeyEvent.VK_W;
		controlDown = java.awt.event.KeyEvent.VK_S;
		controlLeft = java.awt.event.KeyEvent.VK_A;
		controlRight = java.awt.event.KeyEvent.VK_D;
		controlConfirm = java.awt.event.KeyEvent.VK_ENTER;
		controlCancel = java.awt.event.KeyEvent.VK_BACK_SPACE;
		controlQuit = java.awt.event.KeyEvent.VK_ESCAPE;
		controlUpgrade = java.awt.event.KeyEvent.VK_Q;
		controlCustomize = java.awt.event.KeyEvent.VK_E;
		controlToggleFullScreen = KeyEvent.VK_F12;
	}
	
	/*@ requires true
	  @ ensures SaveFile.getCurrentFile().controlUp == Constants.controlUp;
	  @ ensures SaveFile.getCurrentFile().controlDown == Constants.controlDown;
	  @ ensures SaveFile.getCurrentFile().controlLeft == Constants.controlLeft;
	  @ ensures SaveFile.getCurrentFile().controlRight == Constants.controlRight;
	  @ ensures SaveFile.getCurrentFile().controlConfirm == Constants.controlConfirm;
	  @ ensures SaveFile.getCurrentFile().controlCancel == Constants.controlCancel;
	  @ ensures SaveFile.getCurrentFile().controlQuit == Constants.controlQuit;
	  @ ensures SaveFile.getCurrentFile().controlUpgrade == Constants.controlUpgrade;
	  @ ensures SaveFile.getCurrentFile().controlCustomize == Constants.controlCustomize;
	  @ ensures SaveFile.getCurrentFile().controlToggleFullScreen == Constants.controlToggleFullScreen;
	  @ ensures SaveFile.SaveCurrentFile();
	  @ assignable SaveFile.getCurrentFile().controlUp,
		SaveFile.getCurrentFile().controlDown,
		SaveFile.getCurrentFile().controlLeft,
		SaveFile.getCurrentFile().controlRight,
		SaveFile.getCurrentFile().controlConfirm,
		SaveFile.getCurrentFile().controlCancel,
		SaveFile.getCurrentFile().controlQuit,
		SaveFile.getCurrentFile().controlUpgrade,
		SaveFile.getCurrentFile().controlCustomize,
		SaveFile.getCurrentFile().controlToggleFullScreen;
	 @*/
	public static void setupWeaponAttributes() {
		ArrayList<ArrayList<Integer>> weaponPrice = new ArrayList<ArrayList<Integer>>();
		ArrayList<Integer> price = new ArrayList<Integer>(5);
		price.add(100);
		price.add(500);
		price.add(1000);
		price.add(1500);
		price.add(2000);
		weaponPrice.add(price);
		
		price = new ArrayList<Integer>(5);
		price.add(500);
		price.add(1000);
		price.add(2000);
		price.add(3000);
		price.add(5000);
		weaponPrice.add(price);
		
		price = new ArrayList<Integer>(5);
		price.add(300);
		price.add(800);
		price.add(1500);
		price.add(2000);
		price.add(4000);
		weaponPrice.add(price);
		
		UPGRADE_COSTS.add(weaponPrice);
		
		ArrayList<Integer> maxLevel = new ArrayList<Integer>(3);
		maxLevel.add(5);
		maxLevel.add(5);
		maxLevel.add(5);
		MAX_UPGRADE_STATUS.add(maxLevel);
	}
	
	public static void saveControlsToSaveFile(){
		SaveFile.getCurrentFile().controlUp = Constants.controlUp;
		SaveFile.getCurrentFile().controlDown = Constants.controlDown;
		SaveFile.getCurrentFile().controlLeft = Constants.controlLeft;
		SaveFile.getCurrentFile().controlRight = Constants.controlRight;
		SaveFile.getCurrentFile().controlConfirm = Constants.controlConfirm;
		SaveFile.getCurrentFile().controlCancel = Constants.controlCancel;
		SaveFile.getCurrentFile().controlQuit = Constants.controlQuit;
		SaveFile.getCurrentFile().controlUpgrade = Constants.controlUpgrade;
		SaveFile.getCurrentFile().controlCustomize = Constants.controlCustomize;
		SaveFile.getCurrentFile().controlToggleFullScreen = Constants.controlToggleFullScreen;
		SaveFile.SaveCurrentFile();
	}
	
	
	public static final String SaveFileDir = "SaveFiles/";
	public static final String ResourceDir = "Resources/";
	public static boolean CONSTANTS_SET_UP = false;
	public static final int MAX_LEVELS = 7;
	public static final int NUM_WEAPONS = 3;
	public static final int NUM_WORLDS = 7;
	public static final int NUM_LEVELS_PER_WORLD = 3;
	public static ArrayList<ArrayList<Integer>> MAX_UPGRADE_STATUS;
	public static int NUM_WEAPON_ATTRIBUTES;
	public static ArrayList<ArrayList<ArrayList<Integer>>> UPGRADE_COSTS;
	public static int TitleScreenNum;
	public static int StoryNum;
	public static int GalaxyMapNum;
	public static int LocalMapNum;
	public static int TitleScreenLoadGame;
	public static int controlUp;
	public static int controlDown;
	public static int controlLeft;
	public static int controlRight;
	public static int controlConfirm;
	public static int controlCancel;
	public static int controlQuit;
	public static int controlUpgrade;
	public static int controlCustomize;
	public static int controlToggleFullScreen;
	public static final int width = 1672;
	public static final int height = 968;
	
}
